nlp_architect.data.cdc_resources.relations.wordnet_relation_extraction.WordnetRelationExtraction

class nlp_architect.data.cdc_resources.relations.wordnet_relation_extraction.WordnetRelationExtraction(method: nlp_architect.data.cdc_resources.relations.relation_types_enums.OnlineOROfflineMethod = <OnlineOROfflineMethod.ONLINE: 'online'>, wn_file: str = None)[source]
__init__(method: nlp_architect.data.cdc_resources.relations.relation_types_enums.OnlineOROfflineMethod = <OnlineOROfflineMethod.ONLINE: 'online'>, wn_file: str = None)[source]

Extract Relation between two mentions according to Word Embedding cosine distance

Parameters:
  • method (required) – OnlineOROfflineMethod.{ONLINE/OFFLINE} run against full wordnet or a sub-set of it (default = ONLINE)
  • wn_file (required on OFFLINE mode) – str Location of wordnet subset file to work with

Methods

__init__(method, wn_file) Extract Relation between two mentions according to Word Embedding cosine distance
extract_all_relations(mention_x, mention_y) Try to find if mentions has anyone or more of the relations this class support
extract_derivation(page_x, page_y) Check if input mentions has derivation relation
extract_partial_synset_match(page_x, page_y) Check if input mentions has partial synset relation
extract_relation(mention_x, mention_y, relation) Base Class Check if Sub class support given relation before executing the sub class
extract_same_synset_entity(page_x, page_y) Check if input mentions has same synset relation for entity mentions
extract_sub_relations(mention_x, mention_y, …) Check if input mentions has the given relation between them
get_supported_relations() Return all supported relations by this class
extract_all_relations(mention_x: nlp_architect.common.cdc.mention_data.MentionDataLight, mention_y: nlp_architect.common.cdc.mention_data.MentionDataLight) → Set[nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType][source]

Try to find if mentions has anyone or more of the relations this class support

Parameters:
  • mention_x – MentionDataLight
  • mention_y – MentionDataLight
Returns:

One or more of: RelationType.WORDNET_SAME_SYNSET_ENTITY,

RelationType.WORDNET_SAME_SYNSET_EVENT, RelationType.WORDNET_PARTIAL_SYNSET_MATCH, RelationType.WORDNET_DERIVATIONALLY

Return type:

Set[RelationType]

static extract_derivation(page_x: nlp_architect.data.cdc_resources.data_types.wn.wordnet_page.WordnetPage, page_y: nlp_architect.data.cdc_resources.data_types.wn.wordnet_page.WordnetPage) → nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType[source]

Check if input mentions has derivation relation

Parameters:
  • page_x – WordnetPage
  • page_y – WordnetPage
Returns:

RelationType.WORDNET_DERIVATIONALLY or RelationType.NO_RELATION_FOUND

static extract_partial_synset_match(page_x: nlp_architect.data.cdc_resources.data_types.wn.wordnet_page.WordnetPage, page_y: nlp_architect.data.cdc_resources.data_types.wn.wordnet_page.WordnetPage) → nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType[source]

Check if input mentions has partial synset relation

Parameters:
  • page_x – WordnetPage
  • page_y – WordnetPage
Returns:

RelationType.WORDNET_PARTIAL_SYNSET_MATCH or RelationType.NO_RELATION_FOUND

extract_relation(mention_x: nlp_architect.common.cdc.mention_data.MentionDataLight, mention_y: nlp_architect.common.cdc.mention_data.MentionDataLight, relation: nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType) → nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType

Base Class Check if Sub class support given relation before executing the sub class

Parameters:
  • mention_x – MentionDataLight
  • mention_y – MentionDataLight
  • relation – RelationType
Returns:

relation in case mentions has given relation and

RelationType.NO_RELATION_FOUND otherwise

Return type:

RelationType

static extract_same_synset_entity(page_x: nlp_architect.data.cdc_resources.data_types.wn.wordnet_page.WordnetPage, page_y: nlp_architect.data.cdc_resources.data_types.wn.wordnet_page.WordnetPage) → nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType[source]

Check if input mentions has same synset relation for entity mentions

Parameters:
  • page_x – WordnetPage
  • page_y – WordnetPage
Returns:

RelationType.WORDNET_SAME_SYNSET_ENTITY or RelationType.NO_RELATION_FOUND

extract_sub_relations(mention_x: nlp_architect.common.cdc.mention_data.MentionDataLight, mention_y: nlp_architect.common.cdc.mention_data.MentionDataLight, relation: nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType) → nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType[source]

Check if input mentions has the given relation between them

Parameters:
  • mention_x – MentionDataLight
  • mention_y – MentionDataLight
  • relation – RelationType
Returns:

relation in case mentions has given relation or

RelationType.NO_RELATION_FOUND otherwise

Return type:

RelationType

static get_supported_relations() → List[nlp_architect.data.cdc_resources.relations.relation_types_enums.RelationType][source]

Return all supported relations by this class

Returns:List[RelationType]